package junits.parametric_test;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import java.util.Locale;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath:applicationContext.xml")
public class Main {
    @Test
    public void test(){
        String h = "Hello World!";
        /**
         * Character.toUpperCase()字符串大写方法
         *              charAt()指定字符串下标
         *              substring()返回指定字符串之后的字符串
         *              toLowerCase()把剩余的字符串小写
         */
        /*String s = Character.toUpperCase(h.charAt(0)) + h.substring(1).toLowerCase();
        System.out.println(s);*/

        String[] world = h.split(" ");
        StringBuilder stringBuilder = new StringBuilder();
        for (String s : world) {
            stringBuilder.append(Character.toUpperCase(s.charAt(0)))
                    .append(s.substring(1).toLowerCase())
                    .append(" ");
        }
        String capitalizedString = stringBuilder.toString().trim();     //trim()方法用于删除字符串开头或结尾的任何额外空格。
        System.out.println(capitalizedString);
    }
}
